<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<h1>Gérer les groupes de TD</h1>

<div class="formFilter">
<form method="POST" action="index.php?controller=GroupeTd&action=index">
<table>
    <tbody>
    <tr>
        <th><br><label for="numEp" >Matière (EP)</label></th>
        <td>
            <br><select name="numEp">
                <?php foreach ($listEP as $key => $ep) {
                    ?><option value='<?php echo $ep["numEP"] ?>' <?php echo ($ep["numEP"]==$formFilter->getNumEp()?"selected='selected'":"") ?> ><?php echo $ep["libelleEP"]?></option>
                <?php }?>
            </select>
       </td>
    </tr>
    <tr>
        <th><br><label for="anneeChoisir" >Année</label></th>
        <td>    
            <br><select name="anneeChoisir">
                <?php for ($i = 2000; $i < (intval(date("Y"))+1); $i++) {?>
                <option value="<?php echo $i;?>" <?php echo ($i==$formFilter->getAnneeChoisir()?"selected='selected'":"") ?> ><?php echo $i."-".($i+1);?></option>
                <?php }?>
            </select>
        </td>
    </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2">
                <input class="right btn btn-default" type="submit" value="valider"/> 
            </td>
        </tr>  
    </tfoot>
</table>
</form>
</div>


<div class="resultats">
<p><?php echo count($listEtudiant)?> étudiants trouvés:</p>
<form method="POST" action="index.php?controller=GroupeTd&action=updateGroupes">
<table class="scrollTable liste">
<thead>
<tr><th>Nom</th><th>Prenom</th><th>Numéro de groupe</th></tr>
</thead>
<tbody>
<?php foreach ($listEtudiant as $key => $etudiant) {?>
<tr>
    <td><?php echo $etudiant["NomUtilisateur"];?></td><td><?php echo $etudiant["PrenomUtilisateur"];?></td>
    <td>
        <select name="numGroupes[<?php echo $etudiant["NumUtilisateur"];?>]">
            <option value=""></option>
        <?php 
        $grpSelected=$bda->getGroupeByEtuEP($etudiant["NumUtilisateur"],$formFilter->getNumEp());
        $Listgroupes=$bda->getGroupesByEP($formFilter->getNumEp());
        foreach ($Listgroupes as $key => $grp) {
            ?><option value='<?php echo $grp["idgrp"] ?>' <?php echo (($grpSelected && $grp["idgrp"]==$grpSelected["idgrp"])?"selected='selected'":"") ?> ><?php echo $grp["numgrp"]?></option>
        <?php }?>
        </select>
    </td>
</tr>
<?php }?>
</tbody>
</table>
    <input type="hidden" name="anneeChoisir" value="<?php echo $formFilter->getAnneeChoisir(); ?>"/>
    <input type="hidden" name="numEp" value="<?php echo $formFilter->getNumEp(); ?>"/>
    <br/>
    <input type="submit" class="right btn btn-default" value="Enregistrer"/>    
</form>
</div>    